package firstMaven;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

public class LifecycleBean
		implements BeanNameAware, BeanPostProcessor, BeanFactoryAware, InitializingBean, DisposableBean {

	public void init(){
		System.out.println("init()");
	}
	public void destroy(){

		System.out.println("destroy()");
	}

	public void afterPropertiesSet() throws Exception {
		System.out.println("afterPropertiesSet()");

	}

	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		((DefaultListableBeanFactory)beanFactory).addBeanPostProcessor(this);
		System.out.println("setBeanFactory");

	}

	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessAfterInitialization");
		return bean;
	}

	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("postProcessBeforeInitialization");
		return bean;
	}

	public void setBeanName(String arg0) {
		System.out.println("setBeanName");

	}
	public void destroy1(){
		System.out.println("close()");
	}

}
